package com.dolphin.servicepassengeruser.controller;

import com.dolphin.common.dto.ResponseResult;
import com.dolphin.common.request.VerificationCodeDTO;
import com.dolphin.servicepassengeruser.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        log.info("手机号：" + passengerPhone);

        return userService.loginOrRegister(passengerPhone);
    }

    @GetMapping("/user/{phone}")
    public ResponseResult getUserByPhone(@PathVariable("phone")String phone) {
        log.info("service-pasenger-user:phone:"+phone);
        return userService.getUserByPhone(phone);
    }
}
